home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra / helpful.zip / bootdisk next >
Text File  |  1995-08-21  |  78KB  |  2,304 lines

  1.   The Linux Bootdisk HOWTO
  2.   Graham Chapman, grahamc@zeta.org.au
  3.   v1.02, 25 June 1995
  4.  
  5.   This document describes how to create Linux boot, boot/root and util-
  6.   ity maintenance disks. These disks could be used as rescue disks or to
  7.   test new kernels.
  8.  
  9.   1.  Introduction
  10.  
  11.  
  12.   1.1.  Why Build Boot Disks?
  13.  
  14.   Linux boot disks are useful in a number of situations, such as:
  15.  
  16.   o  Testing a new kernel.
  17.  
  18.   o  Recovering from disk or system failure. Such a failure could be
  19.      anything from a lost boot sector to a disk head crash.
  20.  
  21.   There are several ways of producing boot disks:
  22.  
  23.   o  Use one from a distribution such as Slackware. This will at least
  24.      allow you to boot.
  25.  
  26.   o  Use a rescue package to set up disks designed to be used as rescue
  27.      disks.
  28.  
  29.   o  Learn what is required for each of the various types of disk to
  30.      operate, then build your own.
  31.  
  32.   I originally chose the last option - learn how it works so that you
  33.   can do it yourself. That way, if something breaks, you can work out
  34.   what to do to fix it. Plus you learn a lot about how Linux works along
  35.   the way. Once I understood how it all worked, then I changed to using
  36.   the Bootkit rescue package to maintain my boot disks.
  37.  
  38.   Experienced Linux users may find little of use in this document.
  39.   However users new to Linux system administration who wish to protect
  40.   against root disk loss and other mishaps may find it useful.
  41.  
  42.   A note on versions - this document has been updated to support the
  43.   following packages and versions:
  44.  
  45.   o  Linux 1.2.0
  46.  
  47.   o  LILO 0.15
  48.  
  49.   Copyright (c) Graham Chapman 1995.
  50.  
  51.   Permission is granted for this material to be freely used and
  52.   distributed, provided the source is acknowledged.  No warranty of any
  53.   kind is provided. You use this material at your own risk.
  54.  
  55.  
  56.   1.2.  Feedback and Credits
  57.  
  58.   I welcome any feedback, good or bad, on the content of this document.
  59.   Please let me know if you find any errors or omissions.
  60.  
  61.   I thank the following people for correcting errors and providing
  62.   useful suggestions for improvement:
  63.  
  64.  
  65.  
  66.  
  67.           Randolph Bentson
  68.           Grant R. Bowman
  69.           Scott Burkett
  70.           Bruce Elliot
  71.           HARIGUCHI Youichi
  72.           Bjxrn-Helge Mevik
  73.           Dwight Spencer
  74.           Cameron Spitzer
  75.           Johannes Stille
  76.  
  77.  
  78.  
  79.  
  80.  
  81.   1.3.  Change History
  82.  
  83.   v1.02, 25 June 1995
  84.  
  85.   o  Add: FAQ question on oversize ramdisk filesystems.
  86.  
  87.   o  Add: if using mkfs, use the -i option.
  88.  
  89.   o  Add: can use cp as well as dd to copy to raw disk.
  90.  
  91.   o  Chg: correct explanation of /dev/fd0 vs /dev/fd0H1440.
  92.  
  93.   o  Chg: use "zImage" terminology to conform to standard usage.
  94.  
  95.   o  Add: mke2fs -m 0 will provide more usable disk space.
  96.  
  97.   o  Add: re-run LILO if the kernel has changed.
  98.  
  99.   o  Add: move rescue packages to new section under "References".
  100.  
  101.   o  Add: new rescue packages Bootkit and CatRescue.
  102.  
  103.   o  Add: FAQ question on cannot execute errors.
  104.  
  105.   o  Add: shell scripts are samples only - I now use Bootkit.
  106.  
  107.   o  Chg: stop using < and > in command examples - too confusing.
  108.  
  109.   o  Chg: sample directory listings are now of diskettes, not model.
  110.  
  111.   o  Chg: use more consistent terminology with ramdisks.
  112.  
  113.      v1.01, 6 February 1995
  114.  
  115.   o  Fix: DO NOT cp kernel_filename /dev/fd0 - this will overwrite any
  116.      file system on the diskette.
  117.  
  118.   o  Fix: Put LILO boot.b and map files on target disk.
  119.  
  120.   o  Add: -dp flags to cp commands to avoid problems.
  121.  
  122.   o  Chg: restructure to try to improve readability.
  123.  
  124.   o  Add: can now use ext2 filesystem on root diskettes.
  125.  
  126.   o  Chg: can now separate boot and root diskettes.
  127.  
  128.   o  Add: credits section in Introduction.
  129.  
  130.   o  Add: FAQ.
  131.  
  132.  
  133.   v1.0, 2 January 1995
  134.  
  135.   o  Converted to conform to HOWTO documentation standards.
  136.  
  137.   o  Added new section - Change History.
  138.  
  139.   o  Various minor corrections.
  140.  
  141.   v0.10, 1 November 1994 Original version, labelled "draft".
  142.  
  143.  
  144.   2.  Disks
  145.  
  146.  
  147.   2.1.  Summary of Disk Types
  148.  
  149.   I classify boot-related disks into 4 types. The discussion here and
  150.   throughout this document uses the term "disk" to refer to diskettes
  151.   unless otherwise specified. Most of the discussion could be equally
  152.   well applied to hard disks.
  153.  
  154.   A summary of disk types and uses is:
  155.  
  156.      boot
  157.         A disk containing a kernel which can be booted. The disk can
  158.         contain a filesystem and use a boot loader to boot, or it can
  159.         simply contain the kernel only at the start of the disk.  The
  160.         disk can be used to boot the kernel using a root file system on
  161.         another disk. This could be useful if you lost your boot loader
  162.         due to, for example, an incorrect installation attempt.
  163.  
  164.  
  165.      root
  166.         A disk with a file system containing everything required to run
  167.         a Linux system. It does not necessarily contain either a kernel
  168.         or a boot loader.
  169.  
  170.         This disk can be used to run the system independently of any
  171.         other disks, once the kernel has been booted. A special kernel
  172.         feature allows a separate root disk to be mounted after booting,
  173.         with the root disk being automatically copied to a ramdisk.
  174.  
  175.         You could use this type of disk to check another disk for
  176.         corruption without mounting it, or to restore another disk after
  177.         a disk failure or loss of files.
  178.  
  179.  
  180.      boot/root
  181.         A disk which is the same as a root disk, but contains a kernel
  182.         and a boot loader. It can be used to boot from, and to run the
  183.         system. The advantage of this type of disk is that is it compact
  184.         - everything required is on a single disk.  However the
  185.         gradually increasing size of everything means that it won't
  186.         necessarily always be possbile to fit everything on a single
  187.         diskette.
  188.  
  189.  
  190.      utility
  191.         A disk which contains a file system, but is not intended to be
  192.         mounted as a root file system. It is an additional data disk.
  193.         You would use this type of disk to carry additional utilities
  194.         where you have too much to fit on your root disk.
  195.  
  196.         The term "utility" only really applies to diskettes, where you
  197.         would use a utility disk to store additional recovery utility
  198.         software.
  199.   2.2.  Boot
  200.  
  201.  
  202.   2.2.1.  Overview
  203.  
  204.   All PC systems start the boot process by executing code in ROM to load
  205.   the sector from sector 0, cylinder 0 of the boot drive and try and
  206.   execute it. On most bootable disks, sector 0, cylinder 0 contains
  207.   either:
  208.  
  209.   o  code from a boot loader such as LILO, which locates the kernel,
  210.      loads it and executes it to start the boot proper.
  211.  
  212.   o  the start of an operating system kernel, such as Linux.
  213.  
  214.   If a Linux kernel has been written to a diskette as a raw device, then
  215.   the first sector will be the first sector of the Linux kernel itself,
  216.   and this sector will continue the boot process by loading the rest of
  217.   the kernel and running Linux. For a more detailed description of the
  218.   boot sector contents, see the documentation in lilo-01.5 or higher.
  219.  
  220.   An alternative method of storing a kernel on a boot disk is to create
  221.   a filesystem, not as a root filesystem, but simply as a means of
  222.   installing LILO and thus allowing boot-time command line options to be
  223.   specified. For example, the same kernel could then be used to boot
  224.   using a hard disk root filesystem, or a diskette root filesystem. This
  225.   could be useful if you were trying to rebuild the hard disk
  226.   filesystem, and wanted to repeatedly test results.
  227.  
  228.  
  229.   2.2.2.  Setting Pointer to Root
  230.  
  231.   The kernel must somehow obtain a pointer to the drive and partititon
  232.   to be mounted as the root drive. This can be provided in several ways:
  233.  
  234.   o  By setting ROOT_DEV = devicename in the Linux kernel makefile and
  235.      rebuilding the kernel (for advice on how to rebuild the kernel,
  236.      read the Linux FAQ and look in /usr/src/linux). Comments in the
  237.      Linux makefile describe the valid values for devicename.
  238.  
  239.   o  By running the rdev utility:
  240.  
  241.  
  242.                rdev filename devicename
  243.  
  244.  
  245.  
  246.  
  247.  
  248.   This will set the root device of the kernel contained in filename to
  249.   be devicename. For example:
  250.  
  251.  
  252.                rdev zImage /dev/sda1
  253.  
  254.  
  255.  
  256.  
  257.  
  258.   This sets the root device in the kernel in zImage to the first parti-
  259.   tion on the first SCSI drive.
  260.  
  261.   There are some alternative ways of issuing the rdev command. Try:
  262.  
  263.  
  264.  
  265.           rdev -h
  266.  
  267.  
  268.  
  269.  
  270.   and it will display command usage.
  271.  
  272.   There is usually no need to configure the root device for boot
  273.   diskette use, because the kernel currently used to boot from probably
  274.   already points to the root drive device. The need can arise, howoever,
  275.   if you obtain a kernel from another machine, for example, from a
  276.   distribution, or if you want to use the kernel to boot a root
  277.   diskette. It is probably a good idea to check the current root drive
  278.   setting, just in case it is wrong. To get rdev to check the current
  279.   root device in a kernel file, enter the command:
  280.  
  281.  
  282.                rdev <filename>
  283.  
  284.  
  285.  
  286.  
  287.   It is possible to change the root device set in a kernel by means
  288.   other than using rdev. For details, see the FAQ at the end of this
  289.   document.
  290.  
  291.  
  292.   2.2.3.  Copying Kernel to Boot Diskette
  293.  
  294.   Once the kernel has been configured then it must be copied to the boot
  295.   diskette.
  296.  
  297.   The commands described below (and throughout the HOWTO) assume that
  298.   the diskettes have been formatted. If not, then use fdformat to format
  299.   the diskettes before continuing.
  300.  
  301.   If the disk is not intended to contain a file system, then the kernel
  302.   can be copied using the dd command, as follows:
  303.  
  304.  
  305.                dd if=infilename of=devicename
  306.  
  307.                where   infilename is the name of the kernel
  308.                and     devicename is the diskette raw device,
  309.                        usually /dev/fd0
  310.  
  311.  
  312.  
  313.  
  314.   The cp command can also be used:
  315.  
  316.  
  317.                cp filename devicename
  318.  
  319.  
  320.  
  321.  
  322.   For example:
  323.  
  324.  
  325.  
  326.                dd if=zImage of=/dev/fd0
  327.        or
  328.                cp zImage /dev/fd0
  329.  
  330.  
  331.   The seek parameter to the dd command should NOT be used. The file must
  332.   be copied to start at the boot sector (sector 0, cylinder 0), and
  333.   omitting the seek parameter will do this.
  334.  
  335.   The output device name to be used is usually /dev/fd0 for the primary
  336.   diskette drive (i.e. drive "A:" in DOS), and /dev/fd1 for the
  337.   secondary. These device names will cause the kernel to autodetect the
  338.   attributes of the drives. Drive attributes can be specified to the
  339.   kernel by using other device names: for example /dev/fd0H1440
  340.   specifies a high density 1.44 Mb drive. It is rare to need to use
  341.   these specific device names.
  342.  
  343.   Where the kernel is to be copied to a boot disk containing a
  344.   filesystem, then the disk is mounted at a suitable point in a
  345.   currently-mounted filesystem, then the cp command is used. For
  346.   example:
  347.  
  348.  
  349.                mount -t ext2 /dev/fd0 /mnt
  350.                cp zImage /mnt
  351.                umount /mnt
  352.  
  353.  
  354.  
  355.  
  356.   Note that for almost all operations in this HOWTO, the user should be
  357.   operating as the superuser.
  358.  
  359.  
  360.   2.3.  Root
  361.  
  362.  
  363.   2.3.1.  Overview
  364.  
  365.   A root disk contains a complete working Linux system, but without
  366.   necessarily including a kernel. In other words, the disk may not be
  367.   bootable, but once the kernel is running, the root disk contains
  368.   everything needed to support a full Linux system. To be able to do
  369.   this, the disk must include the minimum requirements for a Linux
  370.   system:
  371.  
  372.   o  File system.
  373.  
  374.   o  Minimum set of directories - dev, proc, bin, etc, lib, usr, tmp.
  375.  
  376.   o  Basic set of utilities - bash (to run a shell), ls, cp etc.
  377.  
  378.   o  Minimum set of config files - rc, inittab, fstab etc.
  379.  
  380.   o  Runtime library to provide basic functions used by utilities.
  381.  
  382.   Of course, any system only becomes useful when you can run something
  383.   on it, and a root diskette usually only becomes useful when you can do
  384.   something like:
  385.  
  386.   o  Check a file system on another drive, for example to check your
  387.      root file system on your hard drive, you need to be able to boot
  388.      Linux from another drive, as you can with a root diskette system.
  389.      Then you can run fsck on your original root drive while it is not
  390.      mounted.
  391.  
  392.   o  Restore all or part of your original root drive from backup using
  393.      archive/compression utilities including cpio, tar, gzip and ftape.
  394.  
  395.  
  396.  
  397.   2.4.  Boot/Root
  398.  
  399.   This is essentially the same as the root disk, with the addition of a
  400.   kernel and a boot loader such as LILO.
  401.  
  402.   With this configuration, a kernel file is copied to the root file
  403.   system, and LILO is then run to install a configuration which points
  404.   to the kernel file on the target disk. At boot time, LILO will boot
  405.   the kernel from the target disk.
  406.  
  407.   Several files must be copied to the diskette for this method to work.
  408.   Details of these files and the required LILO configuration, including
  409.   a working sample, are given below in the section titled "LILO".
  410.  
  411.  
  412.   2.4.1.  RAM Disks and Root Filesystems on Diskette
  413.  
  414.   For a diskette root filesystem to be efficient, you need to be able to
  415.   run it from a ramdisk, i.e. an emulated disk drive in main memory.
  416.   This avoids having the system run at a snail's pace, which a diskette
  417.   would impose. The Ftape HOWTO states that a ramdisk will be required
  418.   when using Ftape because Ftape requires exclusive use of the diskette
  419.   controller.
  420.  
  421.   There is an added benefit from using a ramdisk - the Linux kernel
  422.   includes an automatic ramdisk root feature, whereby it will, under
  423.   certain circumstances, automatically copy the contents of a root
  424.   diskette to a ramdisk, and then switch the root drive to be the
  425.   ramdisk instead of the diskette. This has two major benefits:
  426.  
  427.   o  The system runs a lot faster.
  428.  
  429.   o  The diskette drive is freed up to allow other diskettes to be used
  430.      on a single-diskette drive system.
  431.  
  432.   The requirements for this feature to be invoked are:
  433.  
  434.   o  The file system on the diskette drive must be either a minix or an
  435.      ext2 file system. The ext2 file system is generally the preferred
  436.      file system to use. Note that if you have a Linux kernel earlier
  437.      than 1.1.73, then you should see the comments in the section titled
  438.      "File Systems" to see whether your kernel will support ext2. If
  439.      your kernel is old then you may have to use minix. This will not
  440.      cause any significant problems.
  441.  
  442.   o  A ramdisk must be configured into the kernel, and it must be at
  443.      least as big as the diskette drive.
  444.  
  445.   A ramdisk can be configured into the kernel in several ways:
  446.  
  447.   o  By uncommenting the RAMDISK macro in the Linux kernel makefile, so
  448.      that it reads:
  449.  
  450.  
  451.                RAMDISK = -DRAMDISK=1440
  452.  
  453.  
  454.  
  455.  
  456.   to define a ramdisk of 1440 1K blocks, the size of a high-density
  457.   diskette.
  458.  
  459.   o  By running the rdev utility, available on most Linux systems. This
  460.      utility displays or sets values for several things in the kernel,
  461.      including the desired size for a ramdisk. To configure a ramdisk of
  462.      1440 blocks into a kernel in a file named zImage, enter:
  463.                rdev -r zImage 1440
  464.  
  465.  
  466.  
  467.  
  468.   this might change in the future, of course. To see what your version
  469.   of rdev does, enter the command:
  470.  
  471.  
  472.                rdev -h
  473.  
  474.  
  475.  
  476.  
  477.   and it should display its options.
  478.  
  479.   o  By using the boot loader package LILO to configure it into your
  480.      kernel at boot time. This can be done using the LILO configuration
  481.      parameter:
  482.  
  483.  
  484.                ramdisk = 1440
  485.  
  486.  
  487.  
  488.  
  489.   to request a ramdisk of 1440 1K blocks at boot time.
  490.  
  491.   o  By interrupting a LILO automatic boot and adding ramdisk=1440 to
  492.      the command line. For example, such a command line might be:
  493.  
  494.  
  495.                zImage ramdisk=1440
  496.  
  497.  
  498.  
  499.  
  500.   See the section on LILO for more details.
  501.  
  502.   o  By editing the kernel file and altering the values near the start
  503.      of the file which record the ramdisk size. This is definitely a
  504.      last resort, but can be done. See the FAQ near the end of this
  505.      document for more details.
  506.  
  507.   The easiest of these methods is LILO configuration, because you need
  508.   to set up a LILO configuration file anyway, so why not add the ramdisk
  509.   size here?
  510.  
  511.   LILO configuration is briefly described in a section titled "LILO"
  512.   below, but it is advisable to obtain the latest stable version of LILO
  513.   from your nearest Linux mirror site, and read the documentation that
  514.   comes with it.
  515.  
  516.   Ramdisks can be made larger than the size of a diskette, and made to
  517.   contain a filesystem as large as the ramdisk. This can be useful to
  518.   load all the software required for rescue work onto a single high-
  519.   performance ramdisk. The method of doing this is described in the FAQ
  520.   section under the question "How can I create an oversize ramdisk
  521.   filesystem?"
  522.  
  523.  
  524.   2.5.  Utility
  525.  
  526.   Often one disk is not sufficient to hold all the software you need to
  527.   be able to perform rescue functions of analysing, repairing and
  528.   restoring corrupted disk drives. By the time you include tar, gzip
  529.   e2fsck, fdisk, Ftape and so on, there is enough for a whole new
  530.   diskette, maybe even more if you want lots of tools.
  531.  
  532.   This means that a rescue set often requires a utility diskette, with a
  533.   file system containing any extra files required. This file system can
  534.   then be mounted at a convenient point, such as /usr, on the boot/root
  535.   system.
  536.  
  537.   Creating a file system is fairly easy, and is described in the section
  538.   titled "File Systems".
  539.  
  540.  
  541.   3.  Components
  542.  
  543.  
  544.   3.1.  File Systems
  545.  
  546.   The Linux kernel now supports two file system types for root disks to
  547.   be automatically copied to ramdisk. These are minix and ext2, of which
  548.   ext2 is the preferred file system.  The ext2 support was added
  549.   sometime between 1.1.17 and 1.1.57, I'm not sure exactly which. If you
  550.   have a kernel within this range then edit
  551.   /usr/src/linux/drivers/block/ramdisk.c and look for the word "ext2".
  552.   If it is not found, then you will have to use a minix file system, and
  553.   therefore the "mkfs" command to create it. (If using mkfs, use the -i
  554.   option to specify more inodes than the default; -i 2000 is suggested).
  555.  
  556.   To create an ext2 file system on a diskette on my system, I issue the
  557.   following command:
  558.  
  559.  
  560.                mke2fs -m 0 /dev/fd0
  561.  
  562.  
  563.  
  564.  
  565.   The mke2fs command will automatically detect the space available and
  566.   configure itself accordingly. If desired, the diskette size in 1Kb
  567.   blocks can be specified to speed up mke2fs operation. The -m 0
  568.   parameter prevents it from reserving space for root, and hence
  569.   provides more usable space on the disk.
  570.  
  571.   An easy way to test the result is to create a system using the above
  572.   command or similar, and then attempt to mount the diskette. If it is
  573.   an ext2 system, then the command:
  574.  
  575.  
  576.                mount -t ext2 /dev/fd0 /<mount point>
  577.  
  578.  
  579.  
  580.  
  581.   should work.
  582.  
  583.  
  584.   3.2.  Kernel
  585.  
  586.  
  587.   3.2.1.  Building a Custom Kernel
  588.  
  589.   In most cases it would be possible to copy your current kernel and
  590.   boot the diskette from that. However there may be cases where you wish
  591.   to build a separate one.
  592.  
  593.   One reason is size.  The kernel is one of the largest files in a
  594.   minimum system, so if you want to build a boot/root diskette, then you
  595.   will have to reduce the size of the kernel as much as possible.  The
  596.   kernel now supports changing the diskette after booting and before
  597.   mounting root, so it is not necessary any more to squeeze the kernel
  598.   into the same disk as everything else, therefore these comments apply
  599.   only if you choose to build a boot/root diskette.
  600.  
  601.   There are two ways of reducing kernel size:
  602.  
  603.   o  Building it with the minumum set of facilities necessary to support
  604.      the desired system. This means leaving out everything you don't
  605.      need. Networking is a good thing to leave out, as well as support
  606.      for any disk drives and other devices which you don't need when
  607.      running your boot/root system.
  608.  
  609.   o  Compressing it, using the standard compressed-kernel option
  610.      included in the makefile:
  611.  
  612.  
  613.                make zImage
  614.  
  615.  
  616.  
  617.  
  618.   Refer to the documentation included with the kernel source for up-to-
  619.   date information on building compressed kernels.  Note that the kernel
  620.   source is usually in /usr/src/linux.
  621.  
  622.   Having worked out a minimum set of facilities to include in a kernel,
  623.   you then need to work out what to add back in. Probably the most
  624.   common uses for a boot/root diskette system would be to examine and
  625.   restore a corrupted root file system, and to do this you may need
  626.   kernel support.
  627.  
  628.   For example, if your backups are all held on tape using Ftape to
  629.   access your tape drive, then, if you lose your current root drive and
  630.   drives containing Ftape, then you will not be able to restore from
  631.   your backup tapes. You will have to reinstall Linux, download and
  632.   reinstall Ftape, and then try and read your backups.
  633.  
  634.   It is probably desirable to maintain a copy of the same version of
  635.   backup utilities used to write the backups, so that you don't waste
  636.   time trying to install versions that cannot read your backup tapes.
  637.  
  638.   The point here is that, whatever I/O support you have added to your
  639.   kernel to support backups should also be added into your boot/root
  640.   kernel.
  641.  
  642.   The procedure for actually building the kernel is described in the
  643.   documentation that comes with the kernel. It is quite easy to follow,
  644.   so start by looking in /usr/src/linux. Note that if you have trouble
  645.   building a kernel, then you should probably not attempt to build
  646.   boot/root systems anyway.
  647.  
  648.  
  649.   3.3.  Devices
  650.  
  651.   A /dev directory containing a special file for all devices to be used
  652.   by the system is mandatory for any Linux system. The directory itself
  653.   is a normal directory, and can be created with the mkdir command in
  654.   the normal way. The device special files, however, must be created in
  655.   a special way, using the mknod command.
  656.  
  657.   There is a shortcut, though - copy your existing /dev directory
  658.   contents, and delete the ones you don't want. The only requirement is
  659.   that you copy the device special files using the -R option. This will
  660.   copy the directory without attempting to copy the contents of the
  661.   files. Note that if you use lower caser, as in "-r", there will be a
  662.   vast difference, because you will probably end up copying the entire
  663.   contents of all of your hard disks - or at least as much of them as
  664.   will fit on a diskette! Therefore, take care, and use the command:
  665.  
  666.  
  667.                cp -dpR /dev /mnt
  668.  
  669.  
  670.  
  671.  
  672.   assuming that the diskette is mounted at /mnt. The dp switches ensure
  673.   that symbolic links are copied as links (rather than the target file
  674.   being copied) and that the original file attributes are preserved,
  675.   thus preserving ownership information.
  676.  
  677.   If you want to do it the hard way, use ls -l to display the major and
  678.   minor device numbers for the devices you want, and create them on the
  679.   diskette using mknod.
  680.  
  681.   Many distributions include a shell script called MAKEDEV in the /dev
  682.   directory. This shell script could be used to create the devices, but
  683.   it is probably easier to just copy your existing ones, especially for
  684.   rescue disk purposes.
  685.  
  686.   Whichever way the device directory is copied, it is worth checking
  687.   that any special devices you need have been placed on the rescue
  688.   diskette. For example, Ftape uses tape devices, so you will need to
  689.   copy all of these.
  690.  
  691.  
  692.   3.4.  Directories
  693.  
  694.   It might be possible to get away with just /dev, /proc and /etc to run
  695.   a Linux system. I don't know - I've never tested it. However a
  696.   reasonable minimum set of directories consists of the following:
  697.  
  698.      /dev
  699.         Required to perform I/O with devices
  700.  
  701.      /proc
  702.         Required by the ps command
  703.  
  704.      /etc
  705.         System configuration files
  706.  
  707.      /bin
  708.         Utility executables considered part of the system
  709.  
  710.      /lib
  711.         Shared libraries to provide run-time support
  712.  
  713.      /mnt
  714.         A mount point for maintenance on other disks
  715.  
  716.      /usr
  717.         Additional utilities and applications
  718.  
  719.   Note that the directory tree presented here is for root diskette use
  720.   only.  Refer to the Linux File System Standard for much better
  721.   information on how file systems should be structured in "standard"
  722.   Linux systems.
  723.  
  724.   Four of these directories can be created very easily:
  725.  
  726.  
  727.   o  /dev is described above in the section titled DEVICES.
  728.  
  729.   o  /proc only needs to exist. Once the directory is created using
  730.      mkdir, nothing more is required.
  731.  
  732.   o  Of the others, /mnt and /usr are included in this list only as
  733.      mount points for use after the boot/root system is running.  Hence
  734.      again, these directories only need to be created.
  735.  
  736.   The remaining 3 directories are described in the following sections.
  737.  
  738.  
  739.   3.4.1.  /etc
  740.  
  741.   This directory must contain a number of configuration files. On most
  742.   systems, these can be divided into 3 groups:
  743.  
  744.   o  Required at all times, e.g. rc, fstab, passwd.
  745.  
  746.   o  May be required, but no-one is too sure.
  747.  
  748.   o  Junk that crept in.
  749.  
  750.   Files which are not essential can be identified with the command:
  751.  
  752.  
  753.                ls -ltru
  754.  
  755.  
  756.  
  757.  
  758.   This lists files in reverse order of date last accessed, so if any
  759.   files are not being accessed, then they can be omitted from a root
  760.   diskette.
  761.  
  762.   On my root diskettes, I have the number of config files down to 15.
  763.   This reduces my work to dealing with three sets of files:
  764.  
  765.   o  The ones I must configure for a boot/root system:
  766.  
  767.  
  768.                rc      system startup script
  769.                fstab   list of file systems to be mounted
  770.                inittab parameters for the init process - the
  771.                        first process started at boot time.
  772.  
  773.  
  774.  
  775.  
  776.  
  777.   o  the ones I should tidy up for a boot/root system:
  778.  
  779.  
  780.                passwd  list of logins
  781.                shadow  contains passwords
  782.  
  783.  
  784.  
  785.  
  786.   These should be pruned on secure systems to avoid copying user's pass-
  787.   words off the system, and so that when you boot from diskette,
  788.   unwanted logins are rejected.
  789.  
  790.   o  The rest. They work at the moment, so I leave them alone.
  791.  
  792.  
  793.   Out of this, I only really have to configure two files, and what they
  794.   should contain is suprisingly small.
  795.  
  796.   o  rc should contain:
  797.  
  798.  
  799.                #!/bin/sh
  800.                /etc/mount -av
  801.                /bin/hostname boot_root
  802.  
  803.  
  804.  
  805.  
  806.   and I don't really need to run hostname - it just looks nicer if I do.
  807.   Even mount is actually only needed to mount /proc to support the ps
  808.   command - Linux will run without it.
  809.  
  810.   o  fstab should contain:
  811.  
  812.  
  813.                /dev/fd0        /               ext2    defaults
  814.                /proc           /proc           proc    defaults
  815.  
  816.  
  817.  
  818.  
  819.   I don't think that the first entry is really needed, but I find that
  820.   if I leave it out, mount won't mount /proc.
  821.  
  822.   Inittab should be ok as is, unless you want to ensure that users on
  823.   serial ports cannot login. To prevent this, comment out all the
  824.   entries for /etc/getty which include a ttys or ttyS device at the end
  825.   of the line.  Leave in the tty ports so that you can login at the
  826.   console.
  827.  
  828.   Inittab defines what the system will run or rerun in various states
  829.   including startup, move to multi-user mode, powerfail, and others.  A
  830.   point to be careful of here is to carefully check that the commands
  831.   entered in inittab refer to programs which are present and to the
  832.   correct directory. If you place your command files on your rescue disk
  833.   using the sample directory listing in this HOWTO as a guide, and then
  834.   copy your inittab to your rescue disk without checking it, then the
  835.   probability of failure will be quite high, because half of the inittab
  836.   entries will refer to missing programs or to the wrong directory.
  837.  
  838.   It is worth noting here as well that some programs cannot be moved
  839.   from one directory to another or they will fail at runtime because
  840.   they have hardcoded the name of another program which they attempt to
  841.   run. For example on my system, /etc/shutdown has hardcoded in it
  842.   /etc/reboot. If I move reboot to /bin/reboot, and then issue a
  843.   shutdown command, it will fail because it can't find the reboot file.
  844.  
  845.   For the rest, just copy all the text files in your /etc directory,
  846.   plus all the executables in your /etc directory that you cannot be
  847.   sure you do not need. As a guide, consult the sample ls listing in
  848.   "Sample Boot/Root ls-lR Directory Listing" - this is what I have, so
  849.   probably it will be sufficient for you if you copy only those files.
  850.  
  851.   In practice, a single rc file is restrictive; most systems now use an
  852.   /etc/rc.d directory containing shell scripts for different run levels.
  853.   The absolute minimum is a single rc script, but it will probably be a
  854.   lot simpler in practice to copy the inittab and /etc/rc.d directory
  855.   from your existing system, and prune the shell scripts in the rc.d
  856.   directory to remove processing not relevent to a diskette system
  857.   environment.
  858.  
  859.   3.4.2.  /bin
  860.  
  861.   Here is a convenient point to place the extra utilities you need to
  862.   perform basic operations, utilities such as ls, mv, cat, dd etc.
  863.  
  864.   See the section titled "Sample Boot/Root ls-lR Directory Listing" for
  865.   the list of files that I place in my boot/root /bin directory. You may
  866.   notice that it does not include any of the utilities required to
  867.   restore from backup, such as cpio, tar, gzip etc. That is because I
  868.   place these on a separate utility diskette, to save space on the
  869.   boot/root diskette. Once I have booted my boot/root diskette, it then
  870.   copies itself to the ramdisk leaving the diskette drive free to mount
  871.   another diskette, the utility diskette. I usually mount this as /usr.
  872.  
  873.   Creation of a utility diskette is described below in the section
  874.   titled "Adding Utility Diskettes".
  875.  
  876.  
  877.   3.4.3.  /lib
  878.  
  879.   Two libraries are required to run many facilities under Linux:
  880.  
  881.   o  ld.so
  882.  
  883.   o  libc.so.4
  884.  
  885.   If they are not found in your /lib directory then the system will be
  886.   unable to boot. If you're lucky you may see an error message telling
  887.   you why.
  888.  
  889.   These should be present in you existing /lib directory. Note that
  890.   libc.so.4 may be a symlink to a libc library with version number in
  891.   the filename. If you issue the command:
  892.  
  893.  
  894.                ls -l /lib
  895.  
  896.  
  897.  
  898.  
  899.   you will see something like:
  900.  
  901.  
  902.                libc.so.4 -> libc.so.4.5.21
  903.  
  904.  
  905.  
  906.  
  907.   In this case, the libc library you want is libc.so.4.5.21.
  908.  
  909.  
  910.   3.5.  LILO
  911.  
  912.  
  913.   3.5.1.  Overview
  914.  
  915.   For the boot/root to be any use, it must be bootable. To achieve this,
  916.   the easiest way is to install a boot loader, which is a piece of
  917.   executable code stored at sector 0, cylinder 0 of the diskette. See
  918.   the section above titled "BOOT DISKETTE" for an overview of the boot
  919.   process.
  920.  
  921.   LILO is a tried and trusted boot loader available from any Linux
  922.   mirror site. It allows you to configure the boot loader, including:
  923.  
  924.  
  925.   o  Which device is to be mounted as the root drive.
  926.  
  927.   o  Whether to use a ramdisk.
  928.  
  929.  
  930.   3.5.2.  Sample LILO Configuration
  931.  
  932.   This provides a very convenient place to specify to the kernel how it
  933.   should boot. My root/boot LILO configuration file, used with LILO
  934.   0.15, is:
  935.  
  936.  
  937.        ______________________________________________________________________
  938.        boot = /dev/fd0
  939.        install = ./mnt/boot.b
  940.        map = ./mnt/lilo.map
  941.        delay = 50
  942.        message = ./mnt/lilo.msg
  943.        timeout = 150
  944.        compact
  945.        image = ./mnt/zImage
  946.                ramdisk = 1440
  947.                root = /dev/fd0
  948.        ______________________________________________________________________
  949.  
  950.  
  951.  
  952.  
  953.   Note that boot.b, lilo.msg and the kernel must first have been copied
  954.   to the diskette using a command similar to:
  955.  
  956.  
  957.        ______________________________________________________________________
  958.        cp /boot/boot.b ./mnt
  959.        ______________________________________________________________________
  960.  
  961.  
  962.  
  963.  
  964.   If this is not done, then LILO will not run correctly at boot time if
  965.   the hard disk is not available, and there is little point setting up a
  966.   rescue disk which requires a hard disk in order to boot.
  967.  
  968.   I run lilo using the command:
  969.  
  970.  
  971.                /sbin/lilo -C <configfile>
  972.  
  973.  
  974.  
  975.  
  976.   I run it from the directory containing the mnt directory where I have
  977.   mounted the diskette. This means that I am telling LILO to install a
  978.   boot loader on the boot device (/dev/fd0 in this case), to boot a
  979.   kernel in the root directory of the diskette.
  980.  
  981.   I have also specified that I want the root device to be the diskette,
  982.   and I want a ramdisk created of 1440 1K blocks, the same size as the
  983.   diskette. Since I have created an ext2 file system on the diskette,
  984.   this completes all the conditions required for Linux to automatically
  985.   switch the root device to the ramdisk, and copy the diskette contents
  986.   there as well.
  987.  
  988.   The ramdisk features of Linux are described further in the section
  989.   above titled "RAM DISKS AND BOOT/ROOT SYSTEMS".
  990.  
  991.   It is also worth considering using the "single" parameter to cause
  992.   Linux to boot in single-user mode. This could be useful to prevent
  993.   users logging in on serial ports.
  994.  
  995.   I also use the "DELAY" "MESSAGE" and "TIMEOUT" statements so that when
  996.   I boot the disk, LILO will give me the opportunity to enter command
  997.   line options if I wish. I don't need them at present, but I never know
  998.   when I might want to set a different root device or mount a filesystem
  999.   read-only.
  1000.  
  1001.   The message file I use contains the message:
  1002.  
  1003.  
  1004.  
  1005.        Linux Boot/Root Diskette
  1006.        ========================
  1007.  
  1008.        Enter a command line of the form:
  1009.  
  1010.              zImage [ command-line options]
  1011.  
  1012.        If nothing is entered, linux will be loaded with
  1013.        defaults after 15 seconds.
  1014.  
  1015.  
  1016.  
  1017.  
  1018.   This is simply a reminder to myself what my choices are.
  1019.  
  1020.   Readers are urged to read the LILO documentation carefully before
  1021.   atttempting to install anything. It is relatively easy to destroy
  1022.   partitions if you use the wrong "boot = " parameter. If you are
  1023.   inexperienced, do NOT run LILO until you are sure you understand it
  1024.   and you have triple-checked your parameters.
  1025.  
  1026.   Note that you must re-run LILO every time you change the kernel, so
  1027.   that LILO can set up its map file to correctly describe the new kernel
  1028.   file. It is in fact possible to replace the kernel file with one which
  1029.   is almost identical without rerunning LILO, but it is far better not
  1030.   to gamble - if you change the kernel, re-run LILO.
  1031.  
  1032.  
  1033.   3.5.3.  Removing LILO
  1034.  
  1035.   One other thing I might as well add here while I'm on the LILO topic:
  1036.   if you mess up lilo on a drive containing DOS, you can always replace
  1037.   the boot sector with the DOS boot loader by issuing the DOS command:
  1038.  
  1039.  
  1040.                FDISK /MBR
  1041.  
  1042.  
  1043.  
  1044.  
  1045.   where MBR stands for "Master Boot Record". Note that some purists
  1046.   disagree with this, and they may have grounds, but it works.
  1047.  
  1048.  
  1049.   3.5.4.  Useful LILO Options
  1050.  
  1051.  
  1052.   LILO has several useful options which are worth keeping in mind when
  1053.   building boot disks:
  1054.  
  1055.   o  Command line options - you can enter command line options to set
  1056.      the root device, ramdisk size, special device parameters, or other
  1057.      things. If you include the DELAY = nn statement in your LILO
  1058.      configuration file, then LILO will pause to allow you to select a
  1059.      kernel image to boot, and to enter, on the same line, any options.
  1060.      For example:
  1061.  
  1062.  
  1063.                zImage aha152x=0x340,11,3,1 ro
  1064.  
  1065.  
  1066.  
  1067.  
  1068.   will pass the aha152x parameters through to the aha152x scsi disk
  1069.   driver (provided that driver has been included when the kernel was
  1070.   built) and will ask for the root filesystem to be mounted read-only.
  1071.  
  1072.   o  Command line "lock" option - this option asks LILO to store the
  1073.      command line entered as the default command line to be used for all
  1074.      future boots. This is particularly useful where you have a device
  1075.      which cannot be autoselected. By using "lock" you can avoid having
  1076.      to type in the device parameter string every time you boot.  For
  1077.      example:
  1078.  
  1079.  
  1080.                zImage aha152x=0x340,11,3,1 root=/dev/sda8 ro lock
  1081.  
  1082.  
  1083.  
  1084.  
  1085.   o  APPEND configuration statement - this allows device parameter
  1086.      strings to be stored in the configuration, as an alternative to
  1087.      using the "lock" command line option. Note that any keywords of the
  1088.      form word=value MUST be enclosed in quotes. For example:
  1089.  
  1090.  
  1091.                APPEND = "aha152x=0x340,11,3,1"
  1092.  
  1093.  
  1094.  
  1095.  
  1096.   o  DELAY configuration statement - this pauses for DELAY tenths of
  1097.      seconds and allows the user to interrupt the automatic boot of the
  1098.      default command line, so that the user can enter an alternate
  1099.      command line.
  1100.  
  1101.  
  1102.   4.  Samples
  1103.  
  1104.  
  1105.   4.1.  Disk Directory Listings
  1106.  
  1107.   This lists the contents of directories from my root and utility
  1108.   diskettes. These lists are provided as an example only of the files
  1109.   included to create a working system. The disks were created using the
  1110.   Bootkit package, which copies to diskette only those files that you
  1111.   want copied.
  1112.  
  1113.  
  1114.   4.1.1.  Root Disk ls-lR Directory Listing
  1115.  
  1116.   The root listing is of a diskette mounted at /mnt.
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.   total 27
  1124.   drwx------   2 root     root         1024 Jun 11 23:23 bin/
  1125.   drwxr-xr-x   2 root     root         3072 Jun 11 23:24 dev/
  1126.   drwxr-xr-x   3 root     root         1024 May 30 06:38 etc/
  1127.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 home/
  1128.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 lib/
  1129.   drwxr-xr-x   2 root     root        12288 Jun 11 23:23 lost+found/
  1130.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 mnt/
  1131.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 proc/
  1132.   drwxr-xr-x   2 root     root         1024 May 30 05:56 root/
  1133.   drwxr-xr-x   2 root     root         1024 Jun  3 23:39 sbin/
  1134.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 tmp/
  1135.   drwxr-xr-x   3 root     root         1024 May 30 05:48 usr/
  1136.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 util/
  1137.   drwxr-xr-x   5 root     root         1024 May 30 05:58 var/
  1138.  
  1139.   /mnt/bin:
  1140.   total 664
  1141.   -rwxr-xr-x   1 root     root       222208 Sep  7  1992 bash*
  1142.   -rwxr-xr-x   1 root     other        4376 Sep  8  1992 cat*
  1143.   -rwxr-xr-x   1 root     other        5088 Sep  4  1992 chmod*
  1144.   -rwxr-xr-x   1 root     other        4024 Sep  4  1992 chown*
  1145.   -rwxr-xr-x   1 root     other       12104 Sep  4  1992 cp*
  1146.   -rwxr-xr-x   1 root     other        4376 Sep  5  1992 cut*
  1147.   -rwxr-xr-x   1 root     other        7592 Sep  4  1992 dd*
  1148.   -rwxr-xr-x   1 root     other        4656 Sep  4  1992 df*
  1149.   -rwxr-xr-x   1 root     root        37892 May  5  1994 e2fsck*
  1150.   -rwx--x--x   1 root     root        14396 Sep 20  1992 fdisk*
  1151.   -r-x--x--x   1 bin      bin          3536 Feb 19 19:14 hostname*
  1152.   -rwxr-xr-x   1 root     other        5292 Sep  4  1992 ln*
  1153.   -rws--x--x   1 root     root        24352 Jan 16  1993 login*
  1154.   -rwxr-xr-x   1 root     other        4104 Sep  4  1992 mkdir*
  1155.   -rwxr-xr-x   1 root     root        21508 May  5  1994 mke2fs*
  1156.   -rwxr-xr-x   1 root     other        3336 Sep  4  1992 mknod*
  1157.   -rwx--x--x   1 root     root         2432 Sep 20  1992 mkswap*
  1158.   -rwxr-xr-x   1 root     root         9596 Jun 10 22:12 mount*
  1159.   -rwxr-xr-x   1 root     other        6724 Sep  4  1992 mv*
  1160.   -rwxr-xr-x   1 root     root        11132 Apr 10  1993 ps*
  1161.   -rwxr-xr-x   1 root     other        5056 Sep  4  1992 rm*
  1162.   -rwxr-xr-x   1 root     root       222208 Sep  7  1992 sh*
  1163.   -rws--x--x   1 root     root        16464 Jan 16  1993 su*
  1164.   -rwxr-xr-x   1 root     root         1204 Sep 17  1992 sync*
  1165.   -rwxr-xr-x   1 root     root         6188 Apr 17  1993 umount*
  1166.  
  1167.   /mnt/dev:
  1168.   total 72
  1169.   -rwxr-xr-x   1 root     root         8331 Mar 14  1993 MAKEDEV*
  1170.   lrwxrwxrwx   1 root     root            4 Jun 11 23:24 console -> tty0
  1171.   crw-rw-rw-   1 root     tty        5,  64 Apr  1  1993 cua0
  1172.   crw-rw-rw-   1 root     tty        5,  65 Mar 19 19:35 cua1
  1173.   crw-rw-rw-   1 root     tty        5,  66 Apr 10  1993 cua2
  1174.   crw-rw-rw-   1 root     tty        5,  67 Apr 10  1993 cua3
  1175.   brw-r--r--   1 root     root       2,   0 Aug 29  1992 fd0
  1176.   brw-r--r--   1 root     root       2,  12 Aug 29  1992 fd0D360
  1177.   brw-r--r--   1 root     root       2,  16 Aug 29  1992 fd0D720
  1178.   brw-r--r--   1 root     root       2,  28 Aug 29  1992 fd0H1440
  1179.   brw-r--r--   1 root     root       2,  12 Aug 29  1992 fd0H360
  1180.   brw-r--r--   1 root     root       2,  16 Aug 29  1992 fd0H720
  1181.   brw-r--r--   1 root     root       2,   4 Aug 29  1992 fd0d360
  1182.   brw-r--r--   1 root     root       2,   8 Jan 15  1993 fd0h1200
  1183.   brw-r--r--   1 root     root       2,  20 Aug 29  1992 fd0h360
  1184.   brw-r--r--   1 root     root       2,  24 Aug 29  1992 fd0h720
  1185.   brw-r--r--   1 root     root       2,   1 Aug 29  1992 fd1
  1186.   brw-r--r--   1 root     root       2,  13 Aug 29  1992 fd1D360
  1187.   brw-r--r--   1 root     root       2,  17 Aug 29  1992 fd1D720
  1188.   brw-r--r--   1 root     root       2,  29 Aug 29  1992 fd1H1440
  1189.   brw-r--r--   1 root     root       2,  13 Aug 29  1992 fd1H360
  1190.   brw-r--r--   1 root     root       2,  17 Aug 29  1992 fd1H720
  1191.   brw-r--r--   1 root     root       2,   5 Aug 29  1992 fd1d360
  1192.   brw-r--r--   1 root     root       2,   9 Aug 29  1992 fd1h1200
  1193.   brw-r--r--   1 root     root       2,  21 Aug 29  1992 fd1h360
  1194.   brw-r--r--   1 root     root       2,  25 Aug 29  1992 fd1h720
  1195.   brw-r-----   1 root     root       3,   0 Aug 29  1992 hda
  1196.   brw-r-----   1 root     root       3,   1 Aug 29  1992 hda1
  1197.   brw-r-----   1 root     root       3,   2 Aug 29  1992 hda2
  1198.   brw-r-----   1 root     root       3,   3 Aug 29  1992 hda3
  1199.   brw-r-----   1 root     root       3,   4 Aug 29  1992 hda4
  1200.   brw-r-----   1 root     root       3,   5 Aug 29  1992 hda5
  1201.   brw-r-----   1 root     root       3,   6 Aug 29  1992 hda6
  1202.   brw-r-----   1 root     root       3,   7 Aug 29  1992 hda7
  1203.   brw-r-----   1 root     root       3,   8 Aug 29  1992 hda8
  1204.   brw-r-----   1 root     root       3,  64 Aug 29  1992 hdb
  1205.   brw-r-----   1 root     root       3,  65 Aug 29  1992 hdb1
  1206.   brw-r-----   1 root     root       3,  66 Aug 29  1992 hdb2
  1207.   brw-r-----   1 root     root       3,  67 Aug 29  1992 hdb3
  1208.   brw-r-----   1 root     root       3,  68 Aug 29  1992 hdb4
  1209.   brw-r-----   1 root     root       3,  69 Aug 29  1992 hdb5
  1210.   brw-r-----   1 root     root       3,  70 Aug 29  1992 hdb6
  1211.   brw-r-----   1 root     root       3,  71 Aug 29  1992 hdb7
  1212.   brw-r-----   1 root     root       3,  72 Aug 29  1992 hdb8
  1213.   crw-r-----   1 root     kmem       1,   2 Aug 29  1992 kmem
  1214.   crw-rw-rw-   1 root     root       6,   0 Aug 29  1992 lp0
  1215.   crw-rw-rw-   1 root     root       6,   1 Aug 29  1992 lp1
  1216.   crw-rw-rw-   1 root     root       6,   2 Aug 29  1992 lp2
  1217.   crw-r-----   1 root     sys        1,   1 Aug 29  1992 mem
  1218.   lrwxrwxrwx   1 root     root            4 Jun 11 23:24 mouse -> cua1
  1219.   crw-rw-rw-   1 root     root      27,   4 Jul 31  1994 nrft0
  1220.   crw-rw-rw-   1 root     root      27,   5 Jul 31  1994 nrft1
  1221.   crw-rw-rw-   1 root     root      27,   6 Jul 31  1994 nrft2
  1222.   crw-rw-rw-   1 root     root      27,   7 Jul 31  1994 nrft3
  1223.   crw-------   1 root     root       9, 128 Jan 23  1993 nrmt0
  1224.   crw-rw-rw-   1 root     root       1,   3 Aug 29  1992 null
  1225.   crw-r-----   1 root     root       6,   0 Aug 29  1992 par0
  1226.   crw-r-----   1 root     root       6,   1 Aug 29  1992 par1
  1227.   crw-r-----   1 root     root       6,   2 Aug 29  1992 par2
  1228.   crw-r-----   1 root     root       1,   4 Aug 29  1992 port
  1229.   crw-rw-rw-   1 root     root       4, 128 Jun 10 00:10 ptyp0
  1230.   crw-rw-rw-   1 root     root       4, 129 Apr 10 14:51 ptyp1
  1231.   crw-rw-rw-   1 root     root       4, 130 Aug 21  1994 ptyp2
  1232.   crw-rw-rw-   1 root     root       4, 131 Apr 12  1993 ptyp3
  1233.   crw-rw-rw-   1 root     tty        4, 132 Jan  3  1993 ptyp4
  1234.   crw-rw-rw-   1 root     tty        4, 133 Jan  3  1993 ptyp5
  1235.   crw-rw-rw-   1 root     tty        4, 134 Jan  3  1993 ptyp6
  1236.   crw-rw-rw-   1 root     tty        4, 135 Jan  3  1993 ptyp7
  1237.   crw-rw-rw-   1 root     tty        4, 136 Jan  3  1993 ptyp8
  1238.   crw-rw-rw-   1 root     tty        4, 137 Jan  3  1993 ptyp9
  1239.   crw-rw-rw-   1 root     tty        4, 138 Jan  3  1993 ptypa
  1240.   crw-rw-rw-   1 root     tty        4, 139 Jan  3  1993 ptypb
  1241.   crw-rw-rw-   1 root     tty        4, 140 Jan  3  1993 ptypc
  1242.   crw-rw-rw-   1 root     tty        4, 141 Jan  3  1993 ptypd
  1243.   crw-rw-rw-   1 root     tty        4, 142 Jan  3  1993 ptype
  1244.   crw-rw-rw-   1 root     tty        4, 143 Jan  3  1993 ptypf
  1245.   brw-rw----   1 root     root       1,   0 Jun  8 18:49 ram
  1246.   crw-rw-rw-   1 root     root      27,   0 Jul 31  1994 rft0
  1247.   crw-rw-rw-   1 root     root      27,   1 Jul 31  1994 rft1
  1248.   crw-rw-rw-   1 root     root      27,   2 Jul 31  1994 rft2
  1249.   crw-rw-rw-   1 root     root      27,   3 Jul 31  1994 rft3
  1250.   crw-------   1 root     root       9,   0 Jan 23  1993 rmt0
  1251.   brw-r-----   1 root     root       8,   0 Aug 29  1992 sda
  1252.   brw-r-----   1 root     root       8,   1 Aug 29  1992 sda1
  1253.   brw-r-----   1 root     root       8,   2 Aug 29  1992 sda2
  1254.   brw-r-----   1 root     root       8,   3 Aug 29  1992 sda3
  1255.   brw-r-----   1 root     root       8,   4 Aug 29  1992 sda4
  1256.   brw-r-----   1 root     root       8,   5 Aug 29  1992 sda5
  1257.   brw-r-----   1 root     root       8,   6 Aug 29  1992 sda6
  1258.   brw-r-----   1 root     root       8,   7 Aug 29  1992 sda7
  1259.   brw-r-----   1 root     root       8,   8 Aug 29  1992 sda8
  1260.   brw-r-----   1 root     root       8,  16 Aug 29  1992 sdb
  1261.   brw-r-----   1 root     root       8,  17 Aug 29  1992 sdb1
  1262.   brw-r-----   1 root     root       8,  18 Aug 29  1992 sdb2
  1263.   brw-r-----   1 root     root       8,  19 Aug 29  1992 sdb3
  1264.   brw-r-----   1 root     root       8,  20 Aug 29  1992 sdb4
  1265.   brw-r-----   1 root     root       8,  21 Aug 29  1992 sdb5
  1266.   brw-r-----   1 root     root       8,  22 Aug 29  1992 sdb6
  1267.   brw-r-----   1 root     root       8,  23 Aug 29  1992 sdb7
  1268.   brw-r-----   1 root     root       8,  24 Aug 29  1992 sdb8
  1269.   brw-------   1 bin      bin        8,  32 Jun 30  1992 sdc
  1270.   brw-------   1 bin      bin        8,  33 Jun 30  1992 sdc1
  1271.   brw-------   1 bin      bin        8,  34 Jun 30  1992 sdc2
  1272.   brw-------   1 bin      bin        8,  35 Jun 30  1992 sdc3
  1273.   brw-------   1 bin      bin        8,  36 Jun 30  1992 sdc4
  1274.   brw-------   1 bin      bin        8,  37 Jun 30  1992 sdc5
  1275.   brw-------   1 bin      bin        8,  38 Jun 30  1992 sdc6
  1276.   brw-------   1 bin      bin        8,  39 Jun 30  1992 sdc7
  1277.   brw-------   1 bin      bin        8,  40 Jun 30  1992 sdc8
  1278.   brw-------   1 bin      bin        8,  48 Jun 30  1992 sdd
  1279.   brw-------   1 bin      bin        8,  49 Jun 30  1992 sdd1
  1280.   brw-------   1 bin      bin        8,  50 Jun 30  1992 sdd2
  1281.   brw-------   1 bin      bin        8,  51 Jun 30  1992 sdd3
  1282.   brw-------   1 bin      bin        8,  52 Jun 30  1992 sdd4
  1283.   brw-------   1 bin      bin        8,  53 Jun 30  1992 sdd5
  1284.   brw-------   1 bin      bin        8,  54 Jun 30  1992 sdd6
  1285.   brw-------   1 bin      bin        8,  55 Jun 30  1992 sdd7
  1286.   brw-------   1 bin      bin        8,  56 Jun 30  1992 sdd8
  1287.   brw-------   1 bin      bin        8,  64 Jun 30  1992 sde
  1288.   brw-------   1 bin      bin        8,  65 Jun 30  1992 sde1
  1289.   brw-------   1 bin      bin        8,  66 Jun 30  1992 sde2
  1290.   brw-------   1 bin      bin        8,  67 Jun 30  1992 sde3
  1291.   brw-------   1 bin      bin        8,  68 Jun 30  1992 sde4
  1292.   brw-------   1 bin      bin        8,  69 Jun 30  1992 sde5
  1293.   brw-------   1 bin      bin        8,  70 Jun 30  1992 sde6
  1294.   brw-------   1 bin      bin        8,  71 Jun 30  1992 sde7
  1295.   brw-------   1 bin      bin        8,  72 Jun 30  1992 sde8
  1296.   crw-rw-rw-   1 root     root       5,   0 Apr 16  1994 tty
  1297.   crw-rw-rw-   1 grahamc  other      4,   0 Jun 11 23:21 tty0
  1298.   crw--w--w-   1 root     root       4,   1 Jun 11 23:23 tty1
  1299.   crw-rw-rw-   1 root     root       4,   2 Jun 11 23:21 tty2
  1300.   crw-rw-rw-   1 root     root       4,   3 Jun 11 23:21 tty3
  1301.   crw-rw-rw-   1 root     other      4,   4 Jun 11 23:21 tty4
  1302.   crw-rw-rw-   1 root     other      4,   5 Jun 11 23:21 tty5
  1303.   crw-rw-rw-   1 root     root       4,   6 Jun 11 23:21 tty6
  1304.   crw--w--w-   1 grahamc  other      4,   7 Apr 15  1993 tty7
  1305.   crw--w--w-   1 root     root       4,   8 Apr 15  1993 tty8
  1306.   crw-rw-rw-   1 root     root       4,  64 Mar 30  1993 ttyS0
  1307.   crw-rw-rw-   1 root     users      4,  65 Mar 31  1993 ttyS1
  1308.   crw-rw-rw-   1 root     root       4,  66 Jan 23  1980 ttyS2
  1309.   crw-rw-rw-   1 root     root       4, 192 Jun 10 00:10 ttyp0
  1310.   crw-rw-rw-   1 root     root       4, 193 Apr 10 14:51 ttyp1
  1311.   crw-rw-rw-   1 root     root       4, 194 Aug 21  1994 ttyp2
  1312.   crw-rw-rw-   1 root     root       4, 195 Apr 12  1993 ttyp3
  1313.   crw-rw-rw-   1 root     tty        4, 196 Jan  3  1993 ttyp4
  1314.   crw-rw-rw-   1 root     tty        4, 197 Jan  3  1993 ttyp5
  1315.   crw-rw-rw-   1 root     tty        4, 198 Jan  3  1993 ttyp6
  1316.   crw-rw-rw-   1 root     tty        4, 199 Jan  3  1993 ttyp7
  1317.   crw-rw-rw-   1 root     tty        4, 200 Jan  3  1993 ttyp8
  1318.   crw-rw-rw-   1 root     tty        4, 201 Jan  3  1993 ttyp9
  1319.   crw-rw-rw-   1 root     tty        4, 202 Jan  3  1993 ttypa
  1320.   crw-rw-rw-   1 root     tty        4, 203 Jan  3  1993 ttypb
  1321.   crw-rw-rw-   1 root     tty        4, 204 Jan  3  1993 ttypc
  1322.   crw-rw-rw-   1 root     tty        4, 205 Jan  3  1993 ttypd
  1323.   crw-rw-rw-   1 root     tty        4, 206 Jan  3  1993 ttype
  1324.   crw-rw-rw-   1 root     tty        4, 207 Jan  3  1993 ttypf
  1325.   -rw-------   1 root     root        63488 Mar 14  1993 ttys0
  1326.   crw-rw-rw-   1 root     root       4,  67 Oct 14  1992 ttys3
  1327.   crw-r--r--   1 root     root       1,   5 Aug 29  1992 zero
  1328.  
  1329.   /mnt/etc:
  1330.   total 108
  1331.   -rw-r--r--   1 root     root           94 May 30 06:15 fstab
  1332.   -rwx------   1 root     root        25604 Mar 17  1993 getty*
  1333.   -rw-------   1 root     root          566 Dec 30  1992 gettydefs
  1334.   -rw-rw-r--   1 root     shadow        321 Oct  3  1994 group
  1335.   -rwxr-xr-x   1 bin      bin          9220 Mar 17  1993 halt*
  1336.   -rw-r--r--   1 root     root           26 Feb 19 19:07 host.conf
  1337.   -rw-r--r--   1 root     root          506 Feb 19 19:07 hosts
  1338.   -rwxr-xr-x   1 bin      bin         17412 Mar 17  1993 init*
  1339.   -rw-r--r--   1 root     root         1354 Jun  3 23:42 inittab
  1340.   -rwxr-xr-x   1 root     root         1478 Mar 17 18:29 issue*
  1341.   -rw-rw----   1 root     shadow       5137 Dec  4  1992 login.defs
  1342.   -rw-r--r--   1 sysadmin bin            42 Mar 17 18:30 motd
  1343.   -rw-r--r--   1 root     shadow        525 Jun 11 23:24 passwd
  1344.   -rwxr-xr-x   1 root     root         1476 Aug 17  1994 profile*
  1345.   -rw-r--r--   1 root     root          715 Feb 19 19:02 protocols
  1346.   drwxr-xr-x   2 root     root         1024 May 30 06:05 rc.d/
  1347.   -rwxr-xr-x   1 bin      bin          9220 Mar 17  1993 reboot*
  1348.   -r--r--r--   1 bin      bin            57 Nov 28  1992 securetty
  1349.   -rw-r--r--   1 root     root         3316 Feb 19 19:01 services
  1350.   -rwxr-xr-x   1 bin      bin         13316 Mar 17  1993 shutdown*
  1351.   -rwxr-xr-x   1 root     root         3212 Apr 17  1993 swapoff*
  1352.   -rwxr-xr-x   1 root     root         3212 Apr 17  1993 swapon*
  1353.   -rw-r--r--   1 root     root          817 Jun 11 23:23 termcap
  1354.   -rwxr-xr-x   1 root     root         6188 Apr 17  1993 umount*
  1355.   -rw-r--r--   1 root     root        12264 Jun 11 23:22 utmp
  1356.   -rw-r--r--   1 root     root           56 Jun 11 23:22 wtmp
  1357.  
  1358.   /mnt/etc/rc.d:
  1359.   total 4
  1360.   -rwxr-xr--   1 root     root          450 May 30 06:05 rc.0*
  1361.   -rwxr-xr--   1 root     root          390 May 30 06:05 rc.K*
  1362.   -rwxr-xr--   1 root     root          683 May 30 06:06 rc.M*
  1363.   -rwxr-xr--   1 root     root          498 Jun 11 18:44 rc.S*
  1364.  
  1365.   /mnt/home:
  1366.   total 0
  1367.  
  1368.   /mnt/lib:
  1369.   total 287
  1370.   -rwxr-xr-x   1 root     root        17412 Jun 11 23:24 ld.so*
  1371.   lrwxrwxrwx   1 root     root           14 Jun 11 23:24 libc.so.4 -> libc.so.4.5.21*
  1372.   -rwxr-xr-x   1 root     root       623620 May 22  1994 libc.so.4.5.21*
  1373.  
  1374.   /mnt/lost+found:
  1375.   total 0
  1376.  
  1377.   /mnt/mnt:
  1378.   total 0
  1379.  
  1380.   /mnt/proc:
  1381.   total 0
  1382.  
  1383.   /mnt/root:
  1384.   total 0
  1385.  
  1386.   /mnt/sbin:
  1387.   total 15
  1388.   -rwxr-xr-x   1 root     root        16885 Jun 13  1994 update*
  1389.  
  1390.   /mnt/tmp:
  1391.   total 0
  1392.  
  1393.   /mnt/usr:
  1394.   total 1
  1395.   drwxr-xr-x   2 root     root         1024 May 30 05:49 bin/
  1396.  
  1397.   /mnt/usr/bin:
  1398.   total 217
  1399.   -rwxr-xr-x   1 root     root         1560 Sep 17  1992 basename*
  1400.   -rws--x--x   1 root     root         8232 Jan 16  1993 chsh*
  1401.   -rwxr-xr-x   1 root     root         1308 Jan 23  1980 clear*
  1402.   -rwxr-xr-x   1 root     other       91136 Sep  4  1992 elvis*
  1403.   -rwxr-xr-x   1 root     root        13252 Sep 17  1992 ls*
  1404.   -rwxr-xr-x   1 bin      bin         21504 Oct  2  1992 more*
  1405.   -rwxr-xr-x   1 root     other       91136 Sep  4  1992 vi*
  1406.  
  1407.   /mnt/util:
  1408.   total 0
  1409.  
  1410.   /mnt/var:
  1411.   total 3
  1412.   drwxr-xr-x   2 root     root         1024 May 30 05:58 adm/
  1413.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 logs/
  1414.   drwxr-xr-x   2 root     root         1024 Jun 11 23:24 run/
  1415.  
  1416.   /mnt/var/adm:
  1417.   total 0
  1418.   -rw-r--r--   1 root     root            0 May 30 05:58 utmp
  1419.   -rw-r--r--   1 root     root            0 May 30 05:58 wtmp
  1420.  
  1421.   /mnt/var/logs:
  1422.   total 0
  1423.  
  1424.   /mnt/var/run:
  1425.   total 0
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.   4.1.2.  Utility Disk ls-lR Directory Listing
  1432.  
  1433.   The utility listing is of a diskette mounted at /mnt.
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.   total 15
  1454.   drwx------   2 root     root         1024 Jun 18 19:57 bin/
  1455.   drwxr-xr-x   2 root     root        12288 Jun 18 19:57 lost+found/
  1456.   drwx------   2 root     root         1024 Jun 18 19:57 sbin/
  1457.   drwxr-xr-x   4 root     root         1024 May  5 16:30 usr/
  1458.  
  1459.   /mnt/bin:
  1460.   total 13
  1461.   -rwxr-xr-x   1 root     root         3180 Apr 10  1993 free*
  1462.   -rwxr-xr-x   1 root     root        10687 Feb 10  1994 pwd*
  1463.   -rwx--x--x   1 root     root         3672 Nov 17  1992 rdev*
  1464.  
  1465.   /mnt/lost+found:
  1466.   total 0
  1467.  
  1468.   /mnt/sbin:
  1469.   total 18
  1470.   -rwxr-xr-x   1 root     root        16336 Jun 18 14:31 insmod*
  1471.   -rwxr-xr-x   1 root     root           68 Jun 18 14:31 lsmod*
  1472.   lrwxrwxrwx   1 root     root            6 Jun 18 19:57 rmmod -> insmod*
  1473.  
  1474.   /mnt/usr:
  1475.   total 2
  1476.   drwx------   2 root     root         1024 Jun 18 19:57 bin/
  1477.   drwxr-xr-x   3 root     root         1024 Jun 18 19:57 local/
  1478.  
  1479.   /mnt/usr/bin:
  1480.   total 411
  1481.   -rwxr-xr-x   1 root     bin        111616 Sep  9  1992 awk*
  1482.   -rwxr-xr-x   1 root     root        41984 Dec 23  1992 cpio*
  1483.   -rwxr-xr-x   1 root     root        50176 Dec 23  1992 find*
  1484.   -rwxr-xr-x   1 root     root       115712 Sep 17  1992 gawk*
  1485.   -rwxr-xr-x   1 root     bin         37888 Sep  4  1992 grep*
  1486.   -rwxr-xr-x   1 root     root        63874 May  1  1994 gzip*
  1487.   -rwxr-xr-x   1 root     root         2044 Sep 17  1992 kill*
  1488.   -rwx--x--x   1 root     root         3132 Jan 24  1993 mt*
  1489.   -rwxr-xr-x   1 root     root         3416 Sep 22  1992 strings*
  1490.   -rwxr-xr-x   1 root     other        3848 Sep  4  1992 who*
  1491.  
  1492.   /mnt/usr/local:
  1493.   total 1
  1494.   drwx------   2 root     root         1024 Jun 18 19:57 bin/
  1495.  
  1496.   /mnt/usr/local/bin:
  1497.   total 374
  1498.   -rwxr-xr-x   1 root     root       155542 Jun 18 17:07 ftape.o*
  1499.   -rwxr-xr-x   1 root     root       226308 Jun 13  1994 tar*
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.   4.2.  Shell Scripts to Build Diskettes
  1506.  
  1507.   These shell scripts are provided as examples only. I no longer use
  1508.   them because I now use and recommend Scott Burkett's Bootkit package
  1509.   to manage rescue diskette contents and creation. Bootkit is based on
  1510.   these scripts, and does essentially the same thing, but it is much
  1511.   tidier, nicer and easier to use. However, the sample shell scripts
  1512.   here will still provide working diskettes.
  1513.  
  1514.   There are two shell scripts:
  1515.  
  1516.   o  mkroot - builds a root or boot/root diskette.
  1517.  
  1518.  
  1519.   o  mkutil - builds a utility diskette.
  1520.  
  1521.   Both are currently configured to run in the parent directory of
  1522.   boot_disk and util_disk, each of which contains everything to be
  1523.   copied to it's diskette. Note that these shell scripts will *NOT*
  1524.   automatically set up and copy all the files for you - you work out
  1525.   which files are needed, set up the directories and copy the files to
  1526.   those directories. The shell scripts are samples which will copy the
  1527.   contents of those directories. Note that they are primitive shell
  1528.   scripts and are not meant for the novice user.
  1529.  
  1530.   The scripts both contain configuration variables at the start which
  1531.   allow them to be easily configured to run anywhere.  First, set up the
  1532.   model directories and copy all the required files into them. To see
  1533.   what directories and files are needed, have a look at the sample
  1534.   directory listings in the previous sections.
  1535.  
  1536.   Check the configuration variables in the shell scripts and change them
  1537.   as required before running the scripts.
  1538.  
  1539.  
  1540.   4.2.1.  mkroot - Make Root or Boot/Root Diskette
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.   ______________________________________________________________________
  1586.   # mkroot: make a boot/boot disk - creates a boot/root diskette
  1587.   #       by building a file system on it, then mounting it and
  1588.   #       copying required files from a model.
  1589.   #       Note: the model to copy from from must dirst be set up,
  1590.   #       then change the configuration variables below to suit
  1591.   #       your system.
  1592.   #
  1593.   # usage: mkroot [nokernel]
  1594.   #       if the parameter is omitted, then the kernel and LILO
  1595.   #       are copied.
  1596.  
  1597.   # Copyright (c) Graham Chapman 1995. All rights reserved.
  1598.   # Permission is granted for this material to be freely
  1599.   # used and distributed, provided the source is acknowledged.
  1600.   # No warranty of any kind is provided. You use this material
  1601.   # at your own risk.
  1602.  
  1603.   # Configuration variables...
  1604.   BOOTDISKDIR=./boot_disk       # name of boot disk directory
  1605.   MOUNTPOINT=./mnt              # temporary mount point for diskette
  1606.   LILODIR=/sbin                 # directory containing lilo
  1607.   LILOBOOT=/boot/boot.b         # lilo boot sector
  1608.   LILOMSG=./lilo.msg            # lilo message to display at boot time
  1609.   LILOCONFIG=./lilo.conf        # lilo parms for boot/root diskette
  1610.   DISKETTEDEV=/dev/fd0          # device name of diskette drive
  1611.  
  1612.   echo $0: create boot/root diskette
  1613.   echo Warning: data on diskette will be overwritten!
  1614.   echo Insert diskette in $DISKETTEDEV and and press any key...
  1615.   read anything
  1616.  
  1617.   mke2fs $DISKETTEDEV
  1618.   if [ $? -ne 0 ]
  1619.   then
  1620.           echo mke2fs failed
  1621.           exit
  1622.   fi
  1623.  
  1624.   mount -t ext2 $DISKETTEDEV $MOUNTPOINT
  1625.   if [ $? -ne 0 ]
  1626.   then
  1627.           echo mount failed
  1628.           exit
  1629.   fi
  1630.  
  1631.   # copy the directories containing files
  1632.   for i in bin etc lib
  1633.   do
  1634.           cp -dpr $BOOTDISKDIR/$i $MOUNTPOINT
  1635.   done
  1636.  
  1637.   # copy dev *without* trying to copy the files in it
  1638.   cp -dpR $BOOTDISKDIR/dev $MOUNTPOINT
  1639.  
  1640.   # create empty directories required
  1641.   mkdir $MOUNTPOINT/proc
  1642.   mkdir $MOUNTPOINT/tmp
  1643.   mkdir $MOUNTPOINT/mnt
  1644.   mkdir $MOUNTPOINT/usr
  1645.  
  1646.   # copy the kernel
  1647.   if [ "$1" != "nokernel" ]
  1648.   then
  1649.           echo "Copying kernel"
  1650.           cp $BOOTDISKDIR/zImage $MOUNTPOINT
  1651.           echo kernel copied
  1652.  
  1653.           # setup lilo
  1654.           cp $LILOBOOT $MOUNTPOINT
  1655.           cp $LILOMSG $MOUNTPOINT
  1656.           $LILODIR/lilo -C $LILOCONFIG
  1657.           echo LILO installed
  1658.   fi
  1659.  
  1660.   umount $MOUNTPOINT
  1661.  
  1662.   echo Root diskette complete
  1663.   ______________________________________________________________________
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.   4.2.2.  mkutil - Make Utility Diskette
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.   ______________________________________________________________________
  1718.   # mkutil: make a utility diskette - creates a utility diskette
  1719.   #       by building a file system on it, then mounting it and
  1720.   #       copying required files from a model.
  1721.   #       Note: the model to copy from from must first be set up,
  1722.   #       then change the configuration variables below to suit
  1723.   #       your system.
  1724.  
  1725.   # Copyright (c) Graham Chapman 1995. All rights reserved.
  1726.   # Permission is granted for this material to be freely
  1727.   # used and distributed, provided the source is acknowledged.
  1728.   # No warranty of any kind is provided. You use this material
  1729.   # at your own risk.
  1730.  
  1731.   # Configuration variables...
  1732.   UTILDISKDIR=./util_disk       # name of directory containing model
  1733.   MOUNTPOINT=./mnt              # temporary mount point for diskette
  1734.   DISKETTEDEV=/dev/fd0          # device name of diskette drive
  1735.  
  1736.   echo $0: create utility diskette
  1737.   echo Warning: data on diskette will be overwritten!
  1738.   echo Insert diskette in $DISKETTEDEV and and press any key...
  1739.   read anything
  1740.  
  1741.   mke2fs $DISKETTEDEV
  1742.   if [ $? -ne 0 ]
  1743.   then
  1744.           echo mke2fs failed
  1745.           exit
  1746.   fi
  1747.  
  1748.   # Any file system type would do here
  1749.   mount -t ext2 $DISKETTEDEV $MOUNTPOINT
  1750.   if [ $? -ne 0 ]
  1751.   then
  1752.           echo mount failed
  1753.           exit
  1754.   fi
  1755.  
  1756.   # copy the directories containing files
  1757.   cp -dpr $UTILDISKDIR/bin $MOUNTPOINT
  1758.  
  1759.   umount $MOUNTPOINT
  1760.  
  1761.   echo Utility diskette complete
  1762.   ______________________________________________________________________
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.   5.  FAQ
  1769.  
  1770.  
  1771.   5.1.  Q. How can I make a boot disk with a XXX driver?
  1772.  
  1773.   The easiest way is to obtain a Slackware kernel from your nearest
  1774.   Slackware mirror site. Slackware kernels are generic kernels which
  1775.   atttempt to include drivers for as many devices as possible, so if you
  1776.   have a SCSI or IDE controller, chances are that a driver for it is
  1777.   included in the Slackware kernel.
  1778.  
  1779.   Go to the a1 directory and select either IDE or SCSI kernel depending
  1780.   on the type of controller you have. Check the xxxxkern.cfg file for
  1781.   the selected kernel to see the drivers which have been included in
  1782.   that kernel. If the device you want is in that list, then the
  1783.   corresponding kernel should boot your computer. Download the
  1784.   xxxxkern.tgz file and copy it to your boot diskette as described above
  1785.   in the section on making boot disks.
  1786.  
  1787.   You must then check the root device in the kernel, using the rdev
  1788.   command:
  1789.  
  1790.  
  1791.                rdev zImage
  1792.  
  1793.  
  1794.  
  1795.  
  1796.   Rdev will then display the current root device in the kernel. If this
  1797.   is not the same as the root device you want, then use rdev to change
  1798.   it.  For example, the kernel I tried was set to /dev/sda2, but my root
  1799.   scsi partition is /dev/sda8. To use a root diskette, you would have to
  1800.   use the command:
  1801.  
  1802.  
  1803.                rdev zImage /dev/fd0
  1804.  
  1805.  
  1806.  
  1807.  
  1808.   If you want to know how to set up a Slackware root disk as well,
  1809.   that's outside the scope of this HOWTO, so I suggest you check the
  1810.   Linux Install Guide or get the Slackware distribution. See the section
  1811.   in this HOWTO titled "References".
  1812.  
  1813.  
  1814.   5.2.  Q. How do I update my boot floppy with a new kernel?
  1815.  
  1816.   Just copy the kernel to your boot diskette using the dd command for a
  1817.   boot diskette without a filesystem, or the cp command for a boot/root
  1818.   disk. Refer to the section in this HOWTO titled "Boot" for details on
  1819.   creating a boot disk. The description applies equally to updating a
  1820.   kernel on a boot disk.
  1821.  
  1822.  
  1823.   5.3.  Q. How do I remove LILO so that I can use DOS to boot again?
  1824.  
  1825.   This is not really a Bootdisk topic, but it is asked so often, so: the
  1826.   answer is, use the DOS command:
  1827.  
  1828.  
  1829.                FDISK /MBR
  1830.  
  1831.  
  1832.  
  1833.  
  1834.   MBR stands for Master Boot Record, and it replaces the boot sector
  1835.   with a clean DOS one, without affecting the partition table. Some
  1836.   purists disagree with this, but even the author of LILO, Werner
  1837.   Almesberger, suggests it. It is easy, and it works.
  1838.  
  1839.   You can also use the dd command to copy the backup saved by LILO to
  1840.   the boot sector - refer to the LILO documentation if you wish to do
  1841.   this.
  1842.  
  1843.  
  1844.   5.4.  Q. How can I boot if I've lost my kernel AND my boot disk?
  1845.  
  1846.   If you don't have a boot disk standing by, then probably the easiest
  1847.   method is to obtain a Slackware kernel for your disk controller type
  1848.   (IDE or SCSI) as described above for "How do I make a boot disk with a
  1849.   XXX driver?". You can then boot your computer using this kernel, then
  1850.   repair whatever damage there is.
  1851.  
  1852.   The kernel you get may not have the root device set to the disk type
  1853.   and partition you want. For example, Slackware's generic scsi kernel
  1854.   has the root device set to /dev/sda2, whereas my root Linux partition
  1855.   happens to be /dev/sda8. In this case the root device in the kernel
  1856.   will have to be changed.
  1857.  
  1858.   You can still change the root device and ramdisk settings in the
  1859.   kernel even if all you have is a kernel, and some other operating
  1860.   system, such as DOS.
  1861.  
  1862.   Rdev changes kernel settings by changing the values at fixed offsets
  1863.   in the kernel file, so you can do the same if you have a hex editor
  1864.   available on whatever systems you do still have running - for example,
  1865.   Norton Utilities Disk Editor under DOS.  You then need to check and if
  1866.   necessary change the values in the kernel at the following offsets:
  1867.  
  1868.  
  1869.        0x01F8  Low byte of RAMDISK size
  1870.        0x01F9  High byte of RAMDISK size
  1871.        0x01FC  Root minor device number - see below
  1872.        0X01FD  Root major device number - see below
  1873.  
  1874.  
  1875.  
  1876.  
  1877.   The ramdisk size is the number of blocks of ramdisk to create.  If you
  1878.   want to boot from a root diskette then set this to decimal 1440, which
  1879.   is 0x05A0, thus set offset 0x01F8 to 0xA0 and offset 0x01F9 to 0x05.
  1880.   This will allocate enough space for a 1.4Mb diskette.
  1881.  
  1882.   The major and minor device numbers must be set to the device you want
  1883.   to mount your root filesystem on. Some useful values to select from
  1884.   are:
  1885.  
  1886.  
  1887.        device          major minor
  1888.        /dev/fd0            2     0   1st floppy drive
  1889.        /dev/hda1           3     1   partition 1 on 1st IDE drive
  1890.        /dev/sda1           8     1   partition 1 on 1st scsi drive
  1891.        /dev/sda8           8     8   partition 8 on 1st scsi drive
  1892.  
  1893.  
  1894.  
  1895.  
  1896.   Once you have set these values then you can write the file to a
  1897.   diskette using either Norton Utilities Disk Editor, or a program
  1898.   called rawrite.exe. This program is included in several distributions,
  1899.   including the SLS and Slackware distributions.  It is a DOS program
  1900.   which writes a file to the "raw" disk, starting at the boot sector,
  1901.   instead of writing it to the file system. If you use Norton Utilities,
  1902.   then you must write the file to a physical disk starting at the
  1903.   beginning of the disk.
  1904.  
  1905.  
  1906.   5.5.  Q. How can I make extra copies of boot/root diskettes?
  1907.  
  1908.   It is never desirable to have just one set of rescue disks - 2 or 3
  1909.   should be kept in case one is unreadable.
  1910.  
  1911.   The easiest way of making copies of any diskettes, including bootable
  1912.   and utility diskettes, is to use the dd command to copy the contents
  1913.   of the original diskette to a file on your hard drive, and then use
  1914.   the same command to copy the file back to a new diskette.  Note that
  1915.   you do not need to, and should not, mount the diskettes, because dd
  1916.   uses the raw device interface.
  1917.  
  1918.   To copy the original, enter the command:
  1919.  
  1920.  
  1921.                dd if=devicename of=filename
  1922.                where   devicename the device name of the diskette
  1923.                        drive
  1924.                and     filename the name of the file where you
  1925.                        want to copy to
  1926.  
  1927.  
  1928.  
  1929.  
  1930.   For example, to copy from /dev/fd0 to a temporary file called
  1931.   /tmp/diskette.copy, I would enter the command:
  1932.  
  1933.  
  1934.                dd if=/dev/fd0 of=/tmp/diskette.copy
  1935.  
  1936.  
  1937.  
  1938.  
  1939.   Omitting the "count" parameter, as we have done here, means that the
  1940.   whole diskette of 2880 (for a high-density) blocks will be copied.
  1941.  
  1942.   To copy the resulting file back to a new diskette, insert the new
  1943.   diskette and enter the reverse command:
  1944.  
  1945.  
  1946.                dd if=filename of=devicename
  1947.  
  1948.  
  1949.  
  1950.  
  1951.   Note that the above discussion assumes that you have only one diskette
  1952.   drive. If you have two of the same type, then you can copy diskettes
  1953.   using a command like:
  1954.  
  1955.  
  1956.                dd if=/dev/fd0 of=/dev/fd1
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.   5.6.  Q. How can I boot without typing in "ahaxxxx=nn,nn,nn" every
  1963.   time?
  1964.  
  1965.   Where a disk device cannot be autodetected it is necessary to supply
  1966.   the kernel with a command device parameter string, such as:
  1967.  
  1968.  
  1969.                aha152x=0x340,11,3,1
  1970.  
  1971.  
  1972.  
  1973.  
  1974.   This parameter string can be supplied in several ways using LILO:
  1975.  
  1976.   o  By entering it on the command line every time the system is booted
  1977.      via LILO. This is boring, though.
  1978.  
  1979.   o  By using the LILO "lock" keyword to make it store the command line
  1980.      as the default command line, so that LILO will use the same options
  1981.      every time it boots.
  1982.  
  1983.   o  By using the APPEND statement in the lilo config file. Note that
  1984.      the parameter string must be enclosed in quotes.
  1985.  
  1986.   For example, a sample command line using the above parameter string
  1987.   would be:
  1988.  
  1989.  
  1990.                zImage  aha152x=0x340,11,3,1 root=/dev/sda1 lock
  1991.  
  1992.  
  1993.  
  1994.  
  1995.   This would pass the device parameter string through, and also ask the
  1996.   kernel to set the root device to /dev/sda1 and save the whole command
  1997.   line and reuse it for all future boots.
  1998.  
  1999.   A sample APPEND statement is:
  2000.  
  2001.  
  2002.                APPEND = "aha152x=0x340,11,3,1"
  2003.  
  2004.  
  2005.  
  2006.  
  2007.   Note that the parameter string must NOT be enclosed in quotes on the
  2008.   command line, but it MUST be enclosed in quotes in the APPEND
  2009.   statement.
  2010.  
  2011.   Note also that for the parameter string to be acted on, the kernel
  2012.   must contain the driver for that disk type. If it does not, then there
  2013.   is nothing listening for the parameter string, and you will have to
  2014.   rebuild the kernel to include the required driver. For details on
  2015.   rebuilding the kernel, cd to /usr/src/linux and read the README, and
  2016.   read the Linux FAQ and Installation HOWTO. Alternatively you could
  2017.   obtain a generic kernel for the disk type and install that.
  2018.  
  2019.   Readers are strongly urged to read the LILO documentation before
  2020.   experimenting with LILO installation. Incautious use of the "BOOT"
  2021.   statement can damage partitions.
  2022.  
  2023.  
  2024.   5.7.  Q. How can I create an oversize ramdisk filesystem?
  2025.  
  2026.   An oversize ramdisk filesystem is a filesystem in a ramdisk larger
  2027.   than the size of the root disk it was loaded from. This can be
  2028.   extremely useful when using Ftape, which requires exclusive use of the
  2029.   floppy disk controller (see the Ftape HOWTO for details.)
  2030.  
  2031.   Two things are required: create an oversize file system on the root
  2032.   diskette, and then patch the kernel so that it will not try to load
  2033.   blocks off the end of the diskette.
  2034.  
  2035.   To create an oversize filesystem, two methods are possible:
  2036.  
  2037.   o  Use the "blocks" e2fsck parameter to specify the size of filesystem
  2038.      that you eventually want in the ramdisk. For example:
  2039.  
  2040.  
  2041.                mke2fs /dev/fd0 3000
  2042.  
  2043.  
  2044.  
  2045.  
  2046.   will create a filesystem on the diskette of 3000 1Kb blocks. The
  2047.   diskette only has 1440 blocks, but mke2fs does not care about this.
  2048.   E2fs will care about it if you try to use more than 1440 blocks of
  2049.   data (allowing for blocks used as inodes and reserved etc), but up to
  2050.   this point it is quite safe. You will soon find out if you try to load
  2051.   too much on the diskette because an I/O error will result.
  2052.  
  2053.   o  Create a partition on your hard disk as large as the filesystem you
  2054.      want on the ramdisk. Then create a filesystem on it and load in the
  2055.      files you want. Then use dd to copy only the first 1440 blocks to
  2056.      diskette, and then check that there was nothing in the uncopied
  2057.      part of the filesystem. For example:
  2058.  
  2059.  
  2060.                dd if=/dev/hdb of=/dev/fd0 bs=1024 count=1440
  2061.                dd if=/dev/hdb of=tailpart bs=1024 skip=1440
  2062.                cmp -l tailparm /dev/zero
  2063.  
  2064.  
  2065.  
  2066.  
  2067.   Of the two, I prefer the first method - it appears easier and safer.
  2068.  
  2069.   The second thing required to get an oversized filesystem is to get the
  2070.   kernel to stop loading at the end of the physical diskette when it
  2071.   tries to load the root diskette into ramdisk. To do this, a simple
  2072.   patch can be applied to the ramdisk driver, which should be found in
  2073.   /usr/src/linux/drivers/block/ramdisk.c. The following patch has been
  2074.   contributed by Bruce Elliot. It is for kernel version 1.2.0, but it
  2075.   should be fairly easy to apply to later versions. Even if the patch
  2076.   will not apply, the code is not complex, so the patch could easily be
  2077.   modified until it worked.
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.   =================================================================
  2114.   X--- ramdisk.c~ Mon Jan 23 13:04:09 1995
  2115.   X+++ ramdisk.c  Mon May 29 00:54:52 1995
  2116.   X@@ -113,6 +113,7 @@
  2117.   X               (struct ext2_super_block *)&sb;
  2118.   X       int             block, tries;
  2119.   X       int             i = 1;
  2120.   X+      int             fblocks;
  2121.   X       int             nblocks;
  2122.   X       char            *cp;
  2123.   X
  2124.   X@@ -168,12 +169,16 @@
  2125.   X                                       nblocks, rd_length >> BLOCK_SIZE_BITS);
  2126.   X                       return;
  2127.   X               }
  2128.   X-              printk("RAMDISK: Loading %d blocks into RAM disk", nblocks);
  2129.   X+              fblocks = blk_size[MAJOR(ROOT_DEV)][MINOR(ROOT_DEV)];
  2130.   X+              if (fblocks > nblocks)
  2131.   X+                      fblocks = nblocks;
  2132.   X+              printk("RAMDISK: Loading %d blocks into %d block filesystem "
  2133.   X+                                      "in RAM disk", fblocks, nblocks);
  2134.   X
  2135.   X               /* We found an image file system.  Load it into core! */
  2136.   X               cp = rd_start;
  2137.   X-              while (nblocks) {
  2138.   X-                      if (nblocks > 2)
  2139.   X+              while (fblocks) {
  2140.   X+                      if (fblocks > 2)
  2141.   X                               bh = breada(ROOT_DEV, block, BLOCK_SIZE, 0,  PAGE_SIZE);
  2142.   X                       else
  2143.   X                               bh = bread(ROOT_DEV, block, BLOCK_SIZE);
  2144.   X@@ -184,7 +189,7 @@
  2145.   X                       }
  2146.   X                       (void) memcpy(cp, bh->b_data, BLOCK_SIZE);
  2147.   X                       brelse(bh);
  2148.   X-                      if (!(nblocks-- & 15)) printk(".");
  2149.   X+                      if (!(fblocks-- & 15)) printk(".");
  2150.   X                       cp += BLOCK_SIZE;
  2151.   X                       block++;
  2152.   X                       i++;
  2153.   =================================================================
  2154.  
  2155.  
  2156.  
  2157.  
  2158.   With this patch, the kernel stops loading at the end of the physical
  2159.   diskette, leaving a filesystem larger than the disk.
  2160.  
  2161.   Some warnings: I have been able to create stable ramdisk filesystems
  2162.   in this fashion of 3500 blocks, but if I try 3600 or more then the
  2163.   kernel collapses with an error something like "fixup table corrupt".
  2164.   I have not been able to track down why, but obviously something is
  2165.   overflowing. Up to 3500 blocks, though, I have had no problems.
  2166.  
  2167.  
  2168.   5.8.  Q. At boot time, I get error A: cannot execute B. Why?
  2169.  
  2170.   There are several cases of program names being hardcoded in various
  2171.   utilities. These cases do not occur everywhere, but they may explain
  2172.   why an executable apparently cannot be found on your system even
  2173.   though you can see that it is there. You can find out if a given
  2174.   program has the name of another hardcoded by using the "strings"
  2175.   command and piping the output through grep.
  2176.  
  2177.   Known examples of hardcoding are:
  2178.  
  2179.   o  Shutdown in some versions has /etc/reboot hardcoded, so reboot must
  2180.      be placed in the /etc directory.
  2181.  
  2182.   o  Init has caused problems for at least one person, with the kernel
  2183.      being unable to find init.
  2184.  
  2185.      To fix these problems, either move the programs to the correct
  2186.      directory, or change configuration files (e.g. inittab) to point to
  2187.      the correct directory. If in doubt, put programs in the same
  2188.      directories as they are on your hard disk, and use the same inittab
  2189.      and /etc/rc.d files as they appear on your hard disk.
  2190.  
  2191.  
  2192.   6.  References
  2193.  
  2194.   In this section, vvv is used in package names in place of the version,
  2195.   to avoid referring here to specific versions. When retrieving a
  2196.   package, always get the latest version unless you have good reasons
  2197.   for not doing so.
  2198.  
  2199.  
  2200.   6.1.  LILO - Linux Loader
  2201.  
  2202.   Written by Werner Almesberger. Excellent boot loader, and the
  2203.   documentation includes information on the boot sector contents and the
  2204.   early stages of the boot process.
  2205.  
  2206.   Ftp from: tsx-11.mit.edu: /pub/linux/packages/lilo/lilo.vvv.tar.gz
  2207.   also on sunsite and mirror sites.
  2208.  
  2209.  
  2210.   6.2.  Linux FAQ and HOWTOs
  2211.  
  2212.   These are available from many sources. Look at the usenet newsgroups
  2213.   news.answers and comp.os.linux.announce.
  2214.  
  2215.   Ftp from: sunsite.unc.edu:/pub/Linux/docs
  2216.  
  2217.   o  FAQ is in /pub/linux/docs/faqs/linux-faq
  2218.  
  2219.   o  HOWTOs are in /pub/Linux/docs/HOWTO
  2220.  
  2221.   For WWW, start at the Linux documentation home page:
  2222.  
  2223.  
  2224.        http://sunsite.unc.edu/mdw/linux.html
  2225.  
  2226.  
  2227.  
  2228.  
  2229.   If desperate, send mail to:
  2230.  
  2231.  
  2232.                mail-server@rtfm.mit.edu
  2233.  
  2234.  
  2235.  
  2236.  
  2237.   with the word "help" in the message, then follow the mailed
  2238.   instructions.
  2239.  
  2240.   Note: if you haven't read the Linux FAQ and related documents such as
  2241.   the Linux Installation HOWTO and the Linux Install Guide, then you
  2242.   should not be trying to build boot diskettes.
  2243.  
  2244.  
  2245.   6.3.  Rescue Packages
  2246.  
  2247.  
  2248.   6.3.1.  Bootkit
  2249.  
  2250.   Written by Scott Burkett. Bootkit provides a flexible menu-driven
  2251.   framework for managing rescue disk creation and contents. It uses the
  2252.   Dialog package to provide nice menus, and a straight-forward directory
  2253.   tree to contain definitions of rescue disk contents. The package
  2254.   includes samples of the main files needed. The package aims to provide
  2255.   only the framework; it is up to the user to work out what to put on
  2256.   the disks and set up the config files accordingly.  For those users
  2257.   who don't mind doing this, it is a good choice.  I use this package
  2258.   myself.
  2259.  
  2260.   Ftp from: sunsite.unc.edu: /pub/Linux/system/Recovery/Bootkit-
  2261.   vvv.tar.gz
  2262.  
  2263.  
  2264.   6.3.2.  CatRescue
  2265.  
  2266.   Written by Oleg Kibirev. This package concentrates on saving space on
  2267.   the rescue diskettes by extensive use of compression, and by
  2268.   implementing executables as shells scripts. The doco includes some
  2269.   tips on what to do in various disaster situations.
  2270.  
  2271.   Ftp from: gd.cs.csufresno.edu/pub/sun4bin/src/CatRescue100.tgz
  2272.  
  2273.  
  2274.   6.3.3.  Rescue Shell Scripts
  2275.  
  2276.   Written by Thomas Heiling. This contains shell scripts to produce boot
  2277.   and boot/root diskettes. It has some dependencies on specific versions
  2278.   of other software such as LILO, and so might need some effort to
  2279.   convert to your system, but it might be useful as a starting point if
  2280.   you wanted more comprehensive shell scripts than are provided in this
  2281.   document.
  2282.  
  2283.   Ftp from: sunsite.unc.edu:/pub/Linux/system/Recovery/rescue.tgz
  2284.  
  2285.  
  2286.   6.3.4.  SAR - Search and Rescue
  2287.  
  2288.   Written by Karel Kubat. SAR produces a rescue diskette, using several
  2289.   techniques to minimize the space required on the diskette.  The manual
  2290.   includes a description of the Linux boot/login process.
  2291.  
  2292.   Ftp from: ftp.icce.rug.nl:/pub/unix/SAR-vvv.tar.gz
  2293.  
  2294.   The manual is available via WWW from:
  2295.  
  2296.   http://www.icce.rug.nl/karel/programs/SAR.html
  2297.  
  2298.  
  2299.   6.4.  Slackware Distribution
  2300.  
  2301.   Apart from being one of the more popular Linux distributions around,
  2302.   it is also a good place to get a generic kernel. It is available from
  2303.   almost everywhere, so there is little point in putting addresses here.
  2304.